home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13896 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: andrew.cmu.edu!dw3u+
  2. From: "Daniel C. Wang" <dw3u+@andrew.cmu.edu>
  3. Newsgroups: comp.lang.c,comp.lang.misc
  4. Subject: Re: GOTO controversy
  5. Date: Wed, 10 Apr 1996 15:26:16 -0400
  6. Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  7. Message-ID: <0lP0hM200YUg06zF40@andrew.cmu.edu>
  8. References: <314FB5F5.259B@simi.is> <3151B47F.70FD@connix.com>
  9.     <4jc1qa$lvv@news.microsoft.com>
  10. NNTP-Posting-Host: po9.andrew.cmu.edu
  11. In-Reply-To: <4jc1qa$lvv@news.microsoft.com>
  12.  
  13.  
  14.  
  15. a-cnadc@microsoft.com (Dann Corbit) writes:
  16. > In article <3151B47F.70FD@connix.com>, shawley@connix.com says...
  17. > >
  18. > >What to you think? Loops without using loops?
  19. > >
  20. > >a loop:
  21. > >
  22. > >for(i=0;i<10;i++)
  23. > >{
  24. > >  stuff
  25. > >}
  26. > >
  27. > >Looping with out a loop
  28. > >
  29. > >no_loop(0,10);
  30. > >
  31. > >no_loop(int start, int end)
  32. > >{
  33. > >    if(start != end) {
  34. > >        stuff
  35. > >        no_loop(start+1,end);
  36. > >    }
  37. > >}
  38. > >
  39. > >I haven't tested this but you get the idea.
  40. > Yes, recursion can be used to loop "without a loop".
  41. > There is no practical advantage to this method.
  42. > The recursive version has 10 function calls to add
  43. > to its overhead.
  44.  
  45. You obviously haven't attempted to write a data flow analysis for a compiler
  46. of a functional language vs. a language with explicate loops. 
  47.  
  48. P.S. in a functional world in-lining a recursive function == loop unrolling
  49. for free. 
  50.  
  51. Course just because it makes the compiler writers life easier its not
  52. necessarily a plus for the programmer, but there is definetly a practical
  53. advantage of some sort.
  54.  
  55.